<template>
  <div class="bigCard" @click="toBigCard" v-if="bigCard">
    <div class="top">
      <div class="authorBox">
        <div class="author">
          <div class="avatar" @click.stop="toUser">
            <van-image
              width="29"
              height="29"
              lazy-load
              round
              :src="
                bigCard.children[0].model.resource.creator
                  ? bigCard.children[0].model.resource.creator.avatar
                  : bigCard.children[0].model.resource.author.userinfo.avatar
              "
            />
          </div>
          <div class="username">
            {{
              bigCard.children[0].model.resource.creator
                ? bigCard.children[0].model.resource.creator.username
                : bigCard.children[0].model.resource.author.userinfo.username
            }}
          </div>
        </div>
        <div class="right" @click.stop="share">
          <svg
            t="1677136516616"
            class="icon"
            viewBox="0 0 1024 1024"
            version="1.1"
            xmlns="http://www.w3.org/2000/svg"
            p-id="4040"
            width="32"
            height="32"
          >
            <path
              d="M512 704c35.2 0 64 28.8 64 64s-28.8 64-64 64-64-28.8-64-64 28.8-64 64-64z m-64-192c0 35.2 28.8 64 64 64s64-28.8 64-64-28.8-64-64-64-64 28.8-64 64z m0-256c0 35.2 28.8 64 64 64s64-28.8 64-64-28.8-64-64-64-64 28.8-64 64z"
              p-id="4041"
              fill="#999999"
            ></path>
          </svg>
        </div>
      </div>
      <div class="title">{{ bigCard.children[0].model.resource.title }}</div>
    </div>
    <div class="img">
      <van-image
        width="360px"
        height="auto"
        lazy-load
        :src="bigCard.children[0].model.resource.cover"
      />
    </div>
    <div class="immediately">立即查看</div>
  </div>
</template>

<script>
import { mapMutations } from "vuex";

export default {
  props: ["bigCard"],
  methods: {
    toUser() {
      this.$router.push({
        path: "/user",
        query: {
          userid: this.bigCard.children[0].model.resource.creator
            ? this.bigCard.children[0].model.resource.creator.id
            : this.bigCard.children[0].model.resource.author.userinfo.id,
        },
      });
    },
    toBigCard() {
      console.log("toBigCard");
    },
    ...mapMutations(["changeShare"]),
    share() {
      // console.log("share");
      this.changeShare();
    },
  },
};
</script>

<style lang="scss" scoped>
.bigCard {
  border-radius: 10px;
  background-color: white;
  margin-bottom: 8px;

  .top {
    padding: 0 10px;

    .authorBox {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 8px 0;

      .author {
        display: flex;
        align-items: center;

        .avatar {
          width: 30px;
          height: 30px;
          border-radius: 50%;
          border: 1px solid #999;
          margin-right: 8px;
          display: flex;
          align-items: center;
          justify-content: center;
        }

        .username {
          font-size: 14px;
          margin-right: 8px;
        }

        .right {
          display: flex;
          justify-content: space-between;

          .icon {
            width: 22px;
          }
        }
      }

      .icon {
        height: 19px;
      }
    }
    .title {
      font-size: 16px;
      font-weight: bold;
      margin-bottom: 8px;
    }
  }

  .img {
    position: relative;
  }

  .immediately {
    color: #999;
    font-size: 12px;
    padding: 6px 15px 10px;
  }
}
</style>
